package com.study.view.util;

import android.content.res.Resources;

/**
 * author : xujianhong
 * date   : 2022/8/19
 * desc   :
 * version: 1.0
 */
public final class UtilView {

    /**
     * dp转换成px
     * @param dpValue
     * @return
     */
    public static float dip2px(float dpValue){
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return dpValue * scale + 0.5F;
    }

    /**
     * sp转换成px
     * @param dpValue
     * @return
     */
    public static float sp2px(float dpValue){
        final float scale = Resources.getSystem().getDisplayMetrics().scaledDensity;
        return dpValue * scale + 0.5F;
    }
}
